<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
 <%@ taglib uri="/mytaglib" prefix="code"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<!-- 下拉框公共JS -->
<script type="text/javascript"
			src="<c:url value="/jsp/base/queryCode.js"/>"></script>

<script type="text/javascript">
	
	$(document).ready(function(){
 			<%-- formatCombobox($(".certTypeId"),"<%=path%>/querycode/listcode.do?codeTypeId=certificate_type");
			formatCombobox($(".conTypeId"),"<%=path%>/querycode/listcode.do?codeTypeId=contact_type");
			formatCombobox($(".addTypeId"),"<%=path%>/querycode/listcode.do?codeTypeId=address_type");
			
			formatCombobox($("#show_gender"),"<%=path%>/querycode/listcode.do?codeTypeId=gender");
			formatCombobox($("#show_degreeId"),"<%=path%>/querycode/listcode.do?codeTypeId=degree");
			formatCombobox($("#show_nationId"),"<%=path%>/querycode/listcode.do?codeTypeId=nation");
			formatCombobox($("#show_isSmoking"),"<%=path%>/querycode/listcode.do?codeTypeId=is_smoking");
			formatCombobox($("#show_country"),"<%=path%>/querycode/listcode.do?codeTypeId=country");
			formatCombobox($("#show_marriageId"),"<%=path%>/querycode/listcode.do?codeTypeId=marriage");
			
			formatCombobox($("#show_relGender"),"<%=path%>/querycode/listcode.do?codeTypeId=gender");
			formatCombobox($("#show_reldegreeId"),"<%=path%>/querycode/listcode.do?codeTypeId=degree");
			formatCombobox($("#show_relnationId"),"<%=path%>/querycode/listcode.do?codeTypeId=nation");
			formatCombobox($("#show_relisSmoking"),"<%=path%>/querycode/listcode.do?codeTypeId=is_smoking");
			formatCombobox($("#show_relcountry"),"<%=path%>/querycode/listcode.do?codeTypeId=country");
			formatCombobox($("#show_relmarriageId"),"<%=path%>/querycode/listcode.do?codeTypeId=marriage"); --%>
			 
			selectLeft();
	});
	 
 
	//选中左侧
	function selectLeft(){
		$(".secondRad").prop("checked",false);
		$('.firstRad').prop("checked",true);
	}
	//选中右侧
	function selectRight(){
		$(".firstRad").prop("checked",false);
		$('.secondRad').prop("checked",true);
	}
	function cancelSimilar(){
		var cifCusId = $('#show_cifCusId').val();
		var relCifId = $('#show_relCifId').val();
		$.ajax({
			url : "<c:url value='../customer/cancelsimilar.do'/>",
			async : false,
			data : {
				cifCusId : cifCusId,
				relCifId : relCifId
			},
			dataType : 'json',
			success : function(data) {
				//return data.codeName;
				alert("aa");
				window.close();
			}

		});
	}
	
 	//合并按钮响应函数
	function mergeCustomer(){
   		 
 		$('#MergeCustomerForm').form('submit',
		{
			url:encodeURI("<c:url value='/customer/mergeCustomer.do'/>"), //查询提交路径
				onSubmit:function()//提交按钮相应函数
			{
			     return $('#MergeCustomerForm').form('validate');
			},
			success:function(data){
				data = eval('(' + data + ')');
				
	       		if(data.success){
	       			var hint = "";
	       			if(data.msg != null){
	       				hint = data.msg;
	       			}else{
	       				hint = "操作成功！";
	       			}
	       			$.messager.alert("提示", hint, 'info',function(){
               			window.close();
           			});
   				}else{
       				$.messager.alert("提示", data.msg, 'warning');
   				}
			},
			error:function(){
				$.messager.alert("错误", "系统错误，请联系管理员！", 'error');
				return;
			}
		});
			
		 
	}
	function formatCombobox(obj,uri){   
	 	obj.combobox({
			url:uri,
			valueField:"codeId",
	        textField:"codeName", 
	        method:"get",
	        editable:false,
	        panelHeight:"auto",
	        hasDownArrow:false
	        
	        /* ,
	        display:none */
	    });
	}
</script>


</head>
<body>
		<form id="MergeCustomerForm" name="MergeCustomerForm" method="post">
		<div class="easyui-panel" >
		   相似原因:${similarReason.remark }
		</div>
		<br>
	<div class="easyui-panel" title="基本信息">
				<table style="border: 0px">
					<tr>
						<td>主客户<input name="similarId" type="hidden" value="${similarId }"></td>
						<td><td>
						<td>疑似客户</td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" id="radCifCusId" class="firstRad" name="cifCusId" onclick="selectLeft()" value = "${cust.baseCus.cifCusId }">主客户CIFID:</td>
						<td width="100px">${cust.baseCus.cifCusId }</td>
						<td width="280px"></td>
 						<td width="120px"><input type="radio" id="radRelCifId" name="cifCusId" class="secondRad" onclick="selectRight()" value = "${relCust.baseCus.cifCusId }">疑似客户CIFID:</td>
						<td width="100px">${relCust.baseCus.cifCusId }</td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" id="radCusName" class="firstRad" name="cusName" value = "${cust.baseCus.cusName }">客户姓名:</td>
						<td width="100px">${cust.baseCus.cusName } </td>
						<td width="280px"></td>
						<td width="120px"><input id="radRelCusName" type="radio" class="secondRad" name="cusName" value = "${relCust.baseCus.cusName }">客户姓名:</td>
						<td width="100px">${relCust.baseCus.cusName }</td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" name="gender" class="firstRad" id="radGender" value = "${cust.baseCus.gender }">性别:</td>
						<td width="100px"><code:codeName codeTypeId="gender" codeId="${cust.baseCus.gender }"/></td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" name="gender" class="secondRad" id="radRelGender" value = "${relCust.baseCus.gender }">性别:</td>
						<td width="100px"><code:codeName codeTypeId="gender" codeId="${relCust.baseCus.gender }"/></td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" name="birthday" class="firstRad" id="radBirthday" value = "<fmt:formatDate value="${cust.baseCus.birthday }" pattern="yyyy-MM-dd"/>"  >出生日期:</td>
						<td width="100px"><fmt:formatDate value="${cust.baseCus.birthday }" pattern="yyyy-MM-dd"/></td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" id="radRelBirthday" class="secondRad" name="birthday" value = "<fmt:formatDate value="${relCust.baseCus.birthday }" pattern="yyyy-MM-dd"/>">出生日期:</td>
						<td width="100px"><fmt:formatDate value="${relCust.baseCus.birthday }" pattern="yyyy-MM-dd"/> </td>
					</tr>
				</table>
 	</div>
	<br />
 	<div class="easyui-panel" title="证件信息">
 		<table >
 			
 			<c:forEach items="${certs }" var="c" varStatus="status">
 					<c:if test="${status.count%2==1}">
	             	<tr>
             		</c:if>
 					<c:if test="${c.certNo == \"empty\" }">
						<td></td><td></td><td width="60px"></td>						
 					</c:if>
 					<c:if test="${c.certNo != \"empty\" }">
										
 				  	<td width="120px">
 				  	   <input type="checkbox" name="certIds" <c:if test="${status.count%2==1}">checked</c:if> value="${c.certId }">
 				  	         
				        <%-- <input type="text" class="certTypeId" id="certTypeId" value="${c.certTypeId }"> --%>
				      	<code:codeName codeTypeId="certificate_type" codeId="${c.certTypeId }"/>:
		                </td><td width="200px">${c.certNo}<input type="hidden" id="certNo" class="certNo" readonly="readonly" value="${c.certNo }">
		             </td>
               		<td width="180px"></td>	
             	</c:if>
             	<c:if test="${status.count%2==0}">
	             	</tr>
             	</c:if>
			</c:forEach>
			
			</table>
 	</div>
	<br />
	<div class="easyui-panel" title="社会及健康属性">
 				<table style="border: 0px;">
					<tr>
						<td width="120px"><input type="radio" id="radheight" class="firstRad" name="height" value="${cust.bodyAttribute.height }">身高(cm):</td>
						<td width="100px">${cust.bodyAttribute.height }</td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" name="height" class="secondRad" value="${relCust.bodyAttribute.height }">身高(cm):</td>
						<td width="100px">${relCust.bodyAttribute.height }</td>
					</tr>
					<tr>
						<td width="120px"><input
				type="radio" name="weight" class="firstRad" value="${cust.bodyAttribute.weight }">体重(kg):</td>
						<td width="100px">${cust.bodyAttribute.weight }</td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" class="secondRad" name="weight" value="${relCust.bodyAttribute.weight }">体重(kg):</td>
						<td width="100px">${relCust.bodyAttribute.weight }</td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" class="firstRad" name="isSmoking" value="${cust.bodyAttribute.isSmoking }">是否吸烟:</td>
						<td width="100px"><code:codeName codeTypeId="is_smoking" codeId="${cust.bodyAttribute.isSmoking }"/></td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" class="secondRad"
				name="isSmoking" value="${relCust.bodyAttribute.isSmoking }">是否吸烟:</td>
						<td width="100px"><code:codeName codeTypeId="is_smoking" codeId="${relCust.bodyAttribute.isSmoking }"/></td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" class="firstRad" name="country" value="${cust.socialAttribute.country }"> 国籍:</td>
						<td width="100px"><code:codeName codeTypeId="country" codeId="${cust.socialAttribute.country }"/></td>
						<td width="280px"></td>
						<td width="120px"> <input type="radio" name="country" class="secondRad" value="${relCust.socialAttribute.country }">国籍:</td>
						<td width="100px"><code:codeName codeTypeId="country" codeId="${relCust.socialAttribute.country }"/></td>
					</tr>
					
					<tr>
						<td width="120px"><input type="radio" class="firstRad" name="nationId" value="${cust.socialAttribute.nationId }"> 民族:</td>
						<td width="100px"><code:codeName codeTypeId="nation" codeId="${cust.socialAttribute.nationId }"/></td>
						<td width="280px"></td>
						<td width="120px"> <input type="radio" class="secondRad"
				name="nationId" value="${relCust.socialAttribute.nationId }"> 民族:</td>
						<td width="100px"><code:codeName codeTypeId="nation" codeId="${relCust.socialAttribute.nationId }"/></td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" class="firstRad"
				name="marriageId" value="${cust.socialAttribute.marriageId }">婚姻状况:</td>
						<td width="100px"><code:codeName codeTypeId="marriage" codeId="${cust.socialAttribute.marriageId }"/></td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" name="marriageId" class="secondRad" value="${relCust.socialAttribute.marriageId }">婚姻状况:</td>
						<td width="100px"><code:codeName codeTypeId="marriage" codeId="${relCust.socialAttribute.marriageId }"/></td>
					</tr>
					 
					<tr>
						<td width="120px"><input type="radio" class="firstRad" name="degreeId" value="${cust.workAttribute.degreeId }">学历:</td>
						<td width="100px"><code:codeName codeTypeId="degree" codeId="${cust.workAttribute.degreeId }"/></td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" class="secondRad"
				name="degreeId" value="${relCust.workAttribute.degreeId }">学历:</td>
						<td width="100px"><code:codeName codeTypeId="degree" codeId="${relCust.workAttribute.degreeId }"/></td>
					</tr>
					<tr>
						<td width="120px"><input type="radio" class="firstRad"
				name="workUnit" value="${cust.workAttribute.workUnit }">工作单位:</td>
						<td width="100px">${cust.workAttribute.workUnit }</td>
						<td width="280px"></td>
						<td width="120px"><input type="radio" class="secondRad" name="workUnit" value="${relCust.workAttribute.workUnit }">工作单位:</td>
						<td width="100px">${relCust.workAttribute.workUnit }</td>
					</tr>
				<tr>
					<td width="120px"><input type="radio" name="yearIncome" class="firstRad" value="${cust.workAttribute.yearIncome }">年收入:</td>
					<td width="100px">${cust.workAttribute.yearIncome }</td>
					<td width="280px"></td>
					<td width="120px"><input type="radio" name="yearIncome" class="secondRad" value="${relCust.workAttribute.yearIncome }">年收入:</td>
					<td width="100px">${relCust.workAttribute.yearIncome }</td>
				</tr>
				</table>
				
 	</div>
	<br />
	<div class="easyui-panel"
		title="联系方式">
		<table >
 		<c:forEach items="${conns }" var="c" varStatus="status">
 			<c:if test="${status.count%2==1}">
	             	<tr>
            </c:if>
            <c:if test="${c.contact == \"empty\" }">
				<td width="320px"></td><td width="180px"></td>						
 			</c:if>
 			<c:if test="${c.contact != \"empty\" }">
										
 				  	<td width="320px">
 				  	   <input type="checkbox" name="contIds" value="${c.conId }" <c:if test="${status.count%2==1}">checked</c:if>>
				       <%-- <input type="text" class="conTypeId" id="conTypeId" value="${c.conTypeId }"> --%>
				       <code:codeName codeTypeId="contact_type" codeId="${c.conTypeId }"/>
		               :${c.contact }<input type="hidden" id="contact" readonly="readonly" class="contact" value="${c.contact }">
 				  	</td>
 				  	<td width="180px"></td>	
             	</c:if>
             	<c:if test="${status.count%2==0}">
	             	</tr>
             	</c:if>     
			</c:forEach>
			</table>
 	</div>
 	
	<br />
	<div class="easyui-panel"
		title="通讯地址">
		<table>
 		<c:forEach items="${addresses }" var="c" varStatus="status">
 			<c:if test="${status.count%2==1}">
	             	<tr>
            </c:if>
             <c:if test="${c.address == \"empty\" }">
				<td width="320px"></td><td width="180px"></td>						
 			</c:if>
 			<c:if test="${c.address != \"empty\" }">
 				<td width="320px">
 				<input type="checkbox" name="addrIds" value="${c.addId }" <c:if test="${status.count%2==1}">checked</c:if>>
 				<code:codeName codeTypeId="address_type" codeId="${c.addTypeId }"/>:${c.address }
				<%-- <input type="text" class="addTypeId" id="conTypeId" value="${c.addTypeId }"> --%>
		        <input type="hidden" id="address" style="width: 300px"  class="address" readonly="readonly" value="${c.address }">
		        </td>
		        	<td width="180px"></td>	
 			</c:if>	  	
 			<c:if test="${status.count%2==0}">
	             	</tr>
	         </c:if>     
			</c:forEach>
		</table>
	</div>
	<br />
	<div align="center"><input type="button" value="合并" onclick="mergeCustomer()">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="解除疑似" onclick="cancelSimilar()"></div>
	</form>
</body>
</html>